package com.fr.chart.axis;

import com.fr.base.Inter;
import com.fr.base.StringUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.DataSeriesCondition;
import com.fr.chart.core.TrendLine;

public class SeriesAttrTrendLine
  implements DataSeriesCondition
{
  private static final long serialVersionUID = -1951481120278096312L;
  public static final String XML_TAG = "SeriesAttrTrendLine";
  private TrendLine line;
  private String name;
  private int forward;
  private int backward;

  public SeriesAttrTrendLine()
  {
    this(null);
  }

  public SeriesAttrTrendLine(TrendLine paramTrendLine)
  {
    this.name = Inter.getLocText("Chart_TrendLine");
    this.forward = 0;
    this.backward = 0;
    this.line = paramTrendLine;
  }

  public void setLine(TrendLine paramTrendLine)
  {
    this.line = paramTrendLine;
  }

  public TrendLine getLine()
  {
    return this.line;
  }

  public void setName(String paramString)
  {
    this.name = paramString;
  }

  public String getName()
  {
    return this.name;
  }

  public void setForward(int paramInt)
  {
    this.forward = paramInt;
  }

  public int getForward()
  {
    return this.forward;
  }

  public void setBackward(int paramInt)
  {
    this.backward = paramInt;
  }

  public int getBackward()
  {
    return this.backward;
  }

  public String getConditionType()
  {
    return "SeriesAttrTrendLine";
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    if (this.line != null)
      return this.line.toJSONObject();
    return null;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("SeriesAttrTrendLine".equals(paramXMLableReader.getTagName())))
      paramXMLableReader.readXMLObject(new XMLReadable(this)
      {
        private final SeriesAttrTrendLine this$0;

        public void readXML()
        {
          if (paramXMLableReader.isChildNode())
          {
            String str1 = paramXMLableReader.getTagName();
            if (str1.equals("TrendLine"))
              SeriesAttrTrendLine.access$002(this.this$0, (TrendLine)paramXMLableReader.readXMLObject(new TrendLine()));
            if (str1.equals("Attr"))
            {
              String str2;
              if ((str2 = paramXMLableReader.getAttr("name")) != null)
                this.this$0.setName(str2);
              if ((str2 = paramXMLableReader.getAttr("forward")) != null)
                this.this$0.setForward(StringUtils.stringToInt(str2));
              if ((str2 = paramXMLableReader.getAttr("backward")) != null)
                this.this$0.setBackward(StringUtils.stringToInt(str2));
            }
          }
        }
      });
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.line != null)
    {
      paramXMLPrintWriter.startTAG("SeriesAttrTrendLine");
      this.line.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.startTAG("Attr").attr("name", this.name).attr("forward", this.forward).attr("backward", this.backward).end();
      paramXMLPrintWriter.end();
    }
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }

  static TrendLine access$002(SeriesAttrTrendLine paramSeriesAttrTrendLine, TrendLine paramTrendLine)
  {
    return (paramSeriesAttrTrendLine.line = paramTrendLine);
  }
}